package poly_array;

public class Teacher extends Person{
    private double salary;

    public Teacher(String name, int age, double salary) {
        super(name, age);
        setSalary(salary);
    }

    public void setSalary(double salary) {
        if(salary >= 1){
            this.salary = salary;
        }
    }

    public double getSalary() {
        return salary;
    }
    //重写父类的say方法
    public String say(){
        return "老师 姓名：" + getName() + "，年龄：" + getAge() + "岁" + " 月薪：" + getSalary() + "元";
    }
    //特有方法
    public void teach(){
        System.out.println("老师" + getName() + "教书");
    }
}
